// page.includeJs 引入 js

var page = require('webpage').create();
page.settings.userAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1";
page.viewportSize = {width: 375, height: 667};

page.open('http://www.xinweishangbaike.cn/classify.php', function () {
    // console.log(page.loadingProgress);
    // console.log(page.libraryPath);      // D:/phpStudy/node/phantomjs_example/antomation
    // console.log(page.loading);          // false

    console.log(JSON.stringify(page.settings));
    /**
     {
         "XSSAuditingEnabled": false,
         "javascriptCanCloseWindows": true,
         "javascriptCanOpenWindows": true,
         "javascriptEnabled": true,
         "loadImages": true,
         "localToRemoteUrlAccessEnabled": false,
         "userAgent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1",
         "webSecurityEnabled": true
     }
     */

    setTimeout(function () {
        page.render(Date.now() + ".png");
        // console.log(page.content);
        // console.log(page.plainText);
        phantom.exit();
    }, 2000);
});
